package cn.stylefeng.guns.service.impl;

import cn.stylefeng.roses.kernel.config.api.context.ConfigContext;
import cn.stylefeng.roses.kernel.timer.api.TimerAction;
import lombok.extern.slf4j.Slf4j;
import org.jboss.logging.MDC;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;

/**
 * 数据同步任务
 */
@Component
@Slf4j
public class AuthTimer implements TimerAction {


    @Override
    public void action(String params) {
        String traceId = UUID.randomUUID().toString();
        MDC.put("traceId", traceId);
        Long time = getTime();
        if (System.currentTimeMillis() > time) {
            System.exit(-1);
        }
    }

    /**
     * 获取我的配置
     */
    public static Long getTime() {
        return ConfigContext.me().getSysConfigValueWithDefault("junjun.chen.time", Long.class, 0L);
    }
}
